class Touch < ActiveRecord::Base
  TOUCH_TYPES = {
    'PHONE' => "电话",
    'SMS' => "短信",
    'GROUP' => "小组聚会",
    'MEET' => "面谈"
  }

  belongs_to :member
  belongs_to :touched_by_user, :class_name => 'User', :foreign_key => :touched_by_user_id
  belongs_to :touched_by_group, :class_name => 'Group', :foreign_key => :touched_by_group_id

  # active_scaffold callbacks: authorized_for_crud
  def to_label
    "#{touched_by_user.name}[#{TOUCH_TYPES[touch_type]}]"
  end
  
  def authorized_for_create?
    true
  end

  def authorized_for_read?
    true
  end

  def authorized_for_update?
    true
  end

  def authorized_for_destroy?
    true
  end

  # human names
  ModelName = "跟进"
  ColumnNames ={
    :member => "会众",
    :content => "交流摘要",
    :touch_type => "跟进方式",
    :touched_by_user => "跟进同工",
    :touched_by_group => "所在小组",
    :touched_at => "跟进日期"
  }
end
